package io.renren.modules.app.service.impl;

import io.renren.modules.app.utils.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.app.dao.ProductDao;
import io.renren.modules.app.entity.ProductEntity;
import io.renren.modules.app.service.ProductService;


@Service("productService")
public class ProductServiceImpl extends ServiceImpl<ProductDao, ProductEntity> implements ProductService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String productName = params.get("key").toString();
        QueryWrapper<ProductEntity> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(productName)) {
            wrapper.like("product_name", productName);
        }
        IPage<ProductEntity> page = this.page(new Query<ProductEntity>().getPage(params), wrapper);
        return new PageUtils(page);
    }

}